package com.learn.algorithm.designpattern.singleton;

/**
 * @author wangxing
 * @version 2020/8/9 16:02 Administrator
 */
public class LazySingletSynchronizedOne {
    private static LazySingletSynchronizedOne lazySingletSynchronizedOne;
    private LazySingletSynchronizedOne(){}

    /**
     * 效率低下,每次获取对象都要获取锁单线程获取数据
     * @return
     */
    public static LazySingletSynchronizedOne getInstance(){
        synchronized (LazySingletSynchronizedOne.class){
            if(lazySingletSynchronizedOne==null){
                lazySingletSynchronizedOne = new LazySingletSynchronizedOne();
            }
        }
        return lazySingletSynchronizedOne;
    }
}
